import http from "../../../utils/http";
import {Api} from "../../../utils/api";

Page({
    data: {
        productInfo: {
            id: 0,
        },
        linkList: []
    },
    onLoad: function (options) {
        const id = options.id
        this.setData({'productInfo.id': id})
    },
    onShow() {
      this.getProductInfo()
    },
    getProductInfo() {
        const id = this.data.productInfo.id
        http.getRequest(Api.getProductInfo, {id}, (res) => {
            const linkList = res.data.linkList
            const productInfo = res.data
            delete productInfo.linkList
            this.setData({productInfo, linkList})
        })
    },
    linkMaterial() {
        const id = this.data.productInfo.id
        wx.navigateTo({
            url: `/pages/product/link/index?id=${id}`,
        })
    }
});
